<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/jquery-3.3.1.js"></script>
    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        .box {
            width: 500px;
            height: 2000px;
            margin: 0 auto;
            position: relative;
        }
        div div{
            width: 100px;
            height: 100px;
            border: 5px solid red;
            padding: 10px;
            margin: 50px;
            position: absolute;
            left: 50px;
            top: 50px;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="box1">

        </div>
        <button class="btn1">点击获取元素尺寸</button>
        <button class="btn2">点击获取元素尺寸+padding</button>
        <button class="btn3">点击获取元素尺寸+padding+border</button>
        <button class="btn4">点击获取元素尺寸+padding+border+margin</button><br>
        <button class="btn5">获取元素到页面的距离</button>
        <button class="btn6">获取元素到父元素边框的距离</button>
        <button class="btn7">获取和设置box的卷去高度</button>
    </div>
    
    <script>
        $(".btn1").click(function(){
            console.log($(".box1").width());
            console.log($(".box1").height());
        });
        $(".btn2").click(function(){
            console.log($(".box1").innerWidth());
            console.log($(".box1").innerHeight());
        });
        $(".btn3").click(function(){
            console.log($(".box1").outerWidth());
            console.log($(".box1").outerHeight());
        });
        $(".btn4").click(function(){
            console.log($(".box1").outerWidth(true));
            console.log($(".box1").outerHeight(true));
        });
        $(".btn5").click(function(){
            console.log($(".box1").offset());
        });
        $(".btn6").click(function(){
            console.log($(".box1").position());
        });
        $(".btn7").click(function(){
            // console.log($(document).scrollTop());
            $(document).scrollTop(700);
        });
    </script>
</body>
</html>